/**
 * Created by dev-001 on 2017/2/27.
 * 得分
 */
import mongoose from 'mongoose';
const Schema = mongoose.Schema;
const ObjectId = Schema.Types.ObjectId;

const ScoreSchema = new Schema({
    score: Number,
    comment: String,
    answer: {
        type: ObjectId,
        ref: 'Answer'
    },
    user: {
        type: ObjectId,
        ref: 'User'
    },
    teacher: {
        type: ObjectId,
        ref: 'User'
    },
    attachment: {
        type: ObjectId,
        ref: 'Attachment'
    },
    createdAt: Date,
    updatedAt: Date
});

ScoreSchema.pre('save', function (next) {
    this.createdAt = new Date();
    next();
});

export default mongoose.model('Score', ScoreSchema);